<template>
	<view>
		<view class="page-foot">
			<view class="ptb10 flex-box flex-align-baseline plr30">
				<view class="fs30 col89">合计：</view>
				<view class="red fs24">¥</view>
				<view class="red fs40 flex-grow-1">{{rentalOrder.renter_pay_money}}</view>
				<view class="g-btn2 fs30 tc" @click="payment()">立即支付</view>
			</view>
		</view>
		<view class="container plr30 ">
			<!-- <view class="sign_box mb30">
				<Signature ref="sig" v-model="v"></Signature>
			</view> -->
			<!-- <view class="fs24 col89">提示：请点击灰色部分并使用工整的字体进行签字</view> -->
			<view class="fs30 col89 mb25 pt50">支付类型</view>
			<view class="pb20 m-hairline--bottom fs30 col10">{{rentalOrder.type}}</view>
			<view class="pt50 mb20 fs30 col89 pt50">押金</view>
			<view class="pb20 m-hairline--bottom fs38 red"><text class="fs32">¥</text>{{rentalOrder.deposit}}</view>
			<view class="pt50 mb20 fs30 col89">租金</view>
			<view class="pb20 m-hairline--bottom fs38 red"><text class="fs32">¥</text>{{rentalOrder.renter_money}}</view>
			<view class="pt50 mb20 fs30 col89">中介费</view>
			<view class="pb20 m-hairline--bottom fs38 red"><text class="fs32">¥</text>{{rentalOrder.renter_medium_money}}</view>
			<view class="pt50 mb20 fs30 col89">支付方式</view>
			<view class="pb20 m-hairline--bottom fs30 col10 mb100">微信支付</view>
		</view>
	</view>
</template>

<script>
	// import Signature from '@/components/sin-signature/sin-signature.vue'
	const core = require('@/xilu/core.js');
	export default {
		data() {
			return {
				rental_order_id:0,
				rentalOrder:{}
				//v: ''
			}
		},
		// components: {
		// 	Signature,
		// },
		onLoad(options) {
			this.rental_order_id = options.rental_order_id;
			this.fetchRentalOrder();
		},
		methods: {
			fetchRentalOrder(){
				core.post({url:"api/xiluhouse.pay/pre_pay_order",data:{rental_order_id:this.rental_order_id},success:(ret)=>{
					 this.rentalOrder = ret.data;
				},loading:false});
			},
			
			payment(){
				core.post({url:"api/xiluhouse.pay/pay",data:{platform:'wxmini',pay_type:1,order_id:this.rental_order_id,type:'rental'},success:(ret)=>{
					 let wxconfig =  ret.data;
					 uni.requestPayment({
					     provider: 'wxpay',
					 	timeStamp: wxconfig.timeStamp,
					 	nonceStr: wxconfig.nonceStr,
					 	package: wxconfig.package,
					 	signType: wxconfig.signType,
					 	paySign: wxconfig.paySign,
					 	success: function (res) {
					 		uni.showToast({
					 			title:'支付成功',
								success() {
									uni.navigateBack({delta:1})
								}
					 		})
					 	},
					 	fail: function (err) {
					 		console.log(err);
					 	}
					 });
				},loading:true});
			}
		}
	}
</script>

<style lang="less" scoped>
	.sign_box {
		height: 480rpx;
		background: #F7F9FC;
		border-radius: 15rpx;
	}

	.mb100 {
		margin-bottom: 100rpx;
	}
</style>
